package Druid;

import com.alibaba.druid.pool.DruidDataSourceFactory;

import javax.sql.DataSource;
import java.io.FileInputStream;
import java.sql.Connection;
import java.util.Properties;

//druid数据库连接池演示
public class druidDemo {
    public static void main(String[] args) throws Exception {
        //1.导入jar包
        //2.定义配置文件
        //3.在家配置文件
        Properties properties = new Properties();
        properties.load(new FileInputStream("jdbc-demo/src/main/resources/druid.properties"));
        //4.获取连接池对象
        DataSource dataSource = DruidDataSourceFactory.createDataSource(properties);
        //5.获取对应的数据库连接
        Connection connection = dataSource.getConnection();
        System.out.println(connection);
    }
}
